var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');

var indexRouter = require('./routes/index');
// 引入 Gg_users表的路由文件
var usersRouter = require('./routes/users');
// 引入 Gg_notices表的路由文件
var noticeRouter = require('./routes/notices');
// 引入 Gg_events表的路由文件
var eventRouter = require('./routes/events');

var app = express();

// 配置 cors 解决跨域
const cors = require('cors');
app.use(cors());

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', indexRouter);
// 配置 Gg_users表的路由
app.use('/users', usersRouter);
// 配置 Gg_notices表的路由
app.use('/notices', noticeRouter);
// 配置 Gg_users表的路由
app.use('/events', eventRouter);

module.exports = app;
